//*****************************************************************************
// JFab (http://code.google.com/p/jfab)
// Copyright (c) 2011 JFab.org
// Admin jfab@jeffreythompson.net
//
// See the file "LICENSE.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//*****************************************************************************

package org.jfab.core;

import org.jfab.core.inflator.CGSpecInflator;
import org.jfab.core.inflator.DefaultInflatorInjector;
import org.jfab.core.inflator.InflatorInjector;
import org.jfab.core.io.DefaultIOInjector;
import org.jfab.core.io.IOInjector;
import org.jfab.core.io.WriterGroup;

/**
 * Provides a default injector.
 */
public class DefaultInjector implements Injector
{
    /** Inflator injector. */
    private final InflatorInjector _inflatorInjector;

    /** Writer injector. */
    private final IOInjector _ioInjector;

    /**
     * Construct this object.
     */
    public DefaultInjector()
    {
        this(new DefaultInflatorInjector(), new DefaultIOInjector());
    }

    /**
     * Construct this object with the given parameters.
     * 
     * @param inflatorInjector Inflator injector.
     * @param ioInjector I/O injector.
     */
    public DefaultInjector(final InflatorInjector inflatorInjector,
            final IOInjector ioInjector)
    {
        _inflatorInjector = inflatorInjector;
        _ioInjector = ioInjector;
    }

    @Override
    public CGSpecInflator injectCGSpecInflator()
    {
        return getInflatorInjector().injectCGSpecInflator();
    }

    /**
     * @see org.jfab.core.Injector#injectJFabber()
     */
    @Override
    public JFabber injectJFabber()
    {
        return new JavaFabber(injectCGSpecInflator(), injectWriterGroup());
    }

    @Override
    public WriterGroup injectWriterGroup()
    {
        return getIOInjector().injectWriterGroup();
    }

    /**
     * @return the inflatorInjector
     */
    private InflatorInjector getInflatorInjector()
    {
        return _inflatorInjector;
    }

    /**
     * @return the ioInjector
     */
    private IOInjector getIOInjector()
    {
        return _ioInjector;
    }
}
